/**
 * Created by yunpeng on 2015/4/20.
 */
var seriesarr = [{
    name: '已发布',
    data: [0, 0]

}, {
    name: '已接受',
    data: [0, 0]

}, {
    name: '取消订单',
    data: [0, 0]

}];
var categoriesarr = [];
var charts;
$(function () {
     $('#container').highcharts({
        chart: {
            type: 'column',
            animation: {
                duration: 1000
            }

        },
        title: {
            text: '每天订单数量'
        },
        subtitle: {
            text: '每天统计一次'
        },
        xAxis: {
            categories: categoriesarr
        },
        yAxis: {
            min: 0,
            title: {
                text: '订单数'
            }
        },
        tooltip: {
            headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
            pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
            '<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
            footerFormat: '</table>',
            shared: true,
            useHTML: true
        },
        plotOptions: {
            column: {
                pointPadding: 0.2,
                borderWidth: 0
            }
        },
        series: seriesarr,
        credits:false
    });
});
charts = $('#container').highcharts();

$('#countdg').datagrid({
    url:'/admin/countList',
    //border : false,
    rownumbers: true,
    idField : 'id',
    pagination : true,
    sortName : 'date',//默认排序的列
    sortOrder: 'desc',
    pageSize : 8,
    pageList : [ 8, 16, 32, 64 ],
    fitColumns : true,
    fit : true,
    checkOnSelect : false,
    selectOnCheck : true,
    striped: true,//条纹交替
    columns:[[
        {field:'',checkbox:true},
        {field:'date',title:'日期',width:100,align:'center'},
        {field:'state1',title:'新发布',width:200,align:'center'},
        {field:'state2',title:'已接受',width:200,align:'center'},
        {field:'state3',title:'取消订单',width:200,align:'center'}
    ]]/*,
    toolbar : '#advicetb'*/
    ,onLoadSuccess:function(data){

        var rows = data.rows;
        seriesarr = [];
        categoriesarr = [];
        var arrstate1 = [];
        var arrstate2 = [];
        var arrstate3 = [];
        for(var i=0;i<rows.length;i++){
            //seriesarr.push({name:''});
            arrstate1.push(rows[i].state1);
            arrstate2.push(rows[i].state2);
            arrstate3.push(rows[i].state3);
            categoriesarr.push(rows[i].date);
        }
       /* seriesarr.push({name:'已发布',data:arrstate1});
        seriesarr.push({name:'已接受',data:arrstate2});
        seriesarr.push({name:'取消订单',data:arrstate3});
        console.log(seriesarr);*/
        charts.series[0].setData(arrstate1);
        charts.series[1].setData(arrstate2);
        charts.series[2].setData(arrstate3);
        charts.xAxis[0].categories = categoriesarr;
        charts.redraw(false);

    }
});

/*


var seriesarr = [{
    name: 'Tokyo',
    data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]

}, {
    name: 'New York',
    data: [83.6, 78.8, 98.5, 93.4, 106.0, 84.5, 105.0, 104.3, 91.2, 83.5, 106.6, 92.3]

}*/
